package com.shdaow.shadow_lib_test;

import java.util.Random;

import com.shadow.shadow_lib._game.DataPoint;
import com.shadow.shadow_lib._game.Histogram;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

public class TestBitmap extends Activity implements OnTouchListener {
	double k = 0;
	ImageView iv;
	Bitmap b;
	Histogram histogram;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		histogram = new Histogram(this);
		setContentView(histogram);
		histogram.setOnTouchListener(this);

	}

	boolean flag = true;

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		/*
		 * if (flag) { flag = false; sa = System.currentTimeMillis(); }
		 * DataPoint dp = new DataPoint(); dp.hen = (System.currentTimeMillis()
		 * - sa) / 1000; dp.shu = event.getY(); histogram.addDatas(dp);
		 * histogram.setO_t(k += 0.1);
		 */
		final Random random = new Random();

		final int flashtime = 5;
		new Thread() {
			public void run() {
				float a = 0;
				while (true) {
					System.out.println(a);
					a += 1f / flashtime;
					if (a > 10)
						histogram.setO_t(a - 10);
					DataPoint dp = new DataPoint();
					dp.hen = a;
					int k = random.nextInt(1000);
					dp.shu = k;
					histogram.addDatas(dp);
					try {
						sleep(1000 / flashtime);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			};
		}.start();
		return false;
	}
}
